export function dateFormatter(str) { // 默认返回yyyy-MM-dd HH-mm-ss
  const hasTime = arguments[1] !== false// 可传第二个参数false，返回yyyy-MM-dd
  const d = new Date(str)
  const year = d.getFullYear()
  const month = (d.getMonth() + 1) < 10 ? '0' + (d.getMonth() + 1) : (d.getMonth() + 1)
  const day = d.getDate() < 10 ? '0' + d.getDate() : d.getDate()
  const hour = d.getHours() < 10 ? '0' + d.getHours() : d.getHours()
  const minute = d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes()
  const second = d.getSeconds() < 10 ? '0' + d.getSeconds() : d.getSeconds()
  if (hasTime) {
    return [year, month, day].join('-') + ' ' + [hour, minute, second].join(':')
  } else {
    return [year, month, day].join('-')
  }
}
